package com.example.healthcondition.controller;

import com.example.healthcondition.entity.DietRecords;
import com.example.healthcondition.services.DietRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/login/home/dietRecords")
public class DietRecordsController {

    private final DietRecordsService dietRecordsService;

    @Autowired
    public DietRecordsController(DietRecordsService dietRecordsService) {
        this.dietRecordsService = dietRecordsService;
    }

    @GetMapping("/{recordId}")
    public DietRecords getDietRecordById(@PathVariable Integer recordId) {
        return dietRecordsService.getDietRecordById(recordId);
    }

    @PostMapping
    public int addDietRecord(@RequestBody DietRecords dietRecords) {
        return dietRecordsService.insertDietRecord(dietRecords);
    }
}